<?php use_helper('I18N', 'Date', 'JavascriptBase') ?>
<?php include_partial('ct_documento/assets') ?>

<ul id="tab" class="nav nav-tabs">
  <li class="active"><a data-toggle="tab" href="#aacr2">AACR2</a></li>
  <?php if (isset($contenido)): ?>
    <li><a data-toggle="tab" href="#contenido">Contenido</a></li>
  <?php endif; ?>
  <?php if ($tipo == 'Detalle'): ?>
    <li><a data-toggle="tab" href="#ver">Detalle</a></li>
  <?php else: ?>
    <li><a data-toggle="tab" href="#ver">Ficha</a></li>
  <?php endif; ?>
</ul>

<div  id="myTabContent" class="tab-content">

  <div class="tab-pane active" id="aacr2">
    <?php if ($tipo == 'Detalle'): ?>
      <div class="accordion" id="accordion1">
        <?php $count = 1 ?>
        <?php foreach ($caracteristicasAACR2 as $titulo => $valor): ?>
          <?php if ($titulo == 'titulo'): ?>
            <div class="well"><h4><?php echo $valor . ':' ?></h4></div>
          <?php else: ?>
            <div class="accordion-group">
              <div class="accordion-heading">
                <a class="accordion-toggle" data-toggle="collapse" href="#<?php echo 'AACR2' . $count ?>">
                  <?php echo $titulo ?>
                </a>
              </div>
              <div id="<?php echo 'AACR2' . $count ?>" class="accordion-body collapse in">
                <div class="accordion-inner">
                  <?php if (!is_string($valor)): ?>
                    <div class="cuerpo_detalle">
                      <table>
                        <?php foreach ($valor as $key => $value): ?>
                          <tr>
                            <th><?php echo $key ?>:</th>
                            <td><?php echo $value ?></td>
                          </tr>
                        <?php endforeach; ?>
                      </table>
                    </div>
                  <?php else: ?>
                    <?php echo $valor ?>
                  <?php endif; ?>
                </div>
              </div>
            </div>
            <?php $count++ ?>
          <?php endif; ?>
        <?php endforeach; ?>
      </div>
    <?php else: ?>
      <div class="cuerpo_detalle">
        <?php foreach ($caracteristicasAACR2 as $caracteristica): ?>
          <div class="well"><?php echo $caracteristica; ?></div>
        <?php endforeach; ?>
      </div>
    <?php endif; ?>
  </div>

  <?php if (isset($contenido)): ?>
    <div class="tab-pane" id="contenido">
      <div class="accordion" id="accordion3">
        <?php $count3 = 1 ?>
        <?php foreach ($contenido as $titulo => $contenido): ?>
          <div class="accordion-group">
            <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" href="#<?php echo 'contenido' . $count3 ?>">
                <?php echo $titulo ?>
              </a>
            </div>
            <div id="<?php echo 'contenido' . $count3 ?>" class="accordion-body collapse in">
              <div class="accordion-inner">
                <div class="cuerpo_detalle">
                  <?php if (is_string($contenido)): ?>
                    <?php echo $contenido ?>
                  <?php else: ?>
                    <?php foreach ($contenido as $valor): ?>
                      <?php echo $valor ?><br />
                    <?php endforeach; ?>
                  <?php endif; ?>
                </div>
              </div>
            </div>
          </div>
          <?php $count3++ ?>
        <?php endforeach; ?>
      </div>
    </div>
  <?php endif; ?>

  <div class="tab-pane" id="ver">
    <div class="accordion" id="accordion2">
      <?php $count2 = 1 ?>
      <?php foreach ($caracteristicas as $titulo => $caracteristica): ?>
        <div class="accordion-group">
          <div class="accordion-heading">
            <a class="accordion-toggle" data-toggle="collapse" href="#<?php echo $tipo . $count2 ?>">
              <?php echo $titulo ?>
            </a>
          </div>
          <?php if (is_string($caracteristica) || is_integer($caracteristica)): ?>
            <div id="<?php echo $tipo . $count2 ?>" class="accordion-body collapse in">
              <div class="accordion-inner">
                <div class="cuerpo_detalle">
                  <p class="detalle_simple"><?php echo $caracteristica ?></p>
                </div>
              </div>
            </div>
          <?php else: ?>
            <div id="<?php echo $tipo . $count2 ?>" class="accordion-body collapse in">
              <div class="accordion-inner">
                <div class="cuerpo_detalle">
                  <table>
                    <?php foreach ($caracteristica as $sub_titulo => $valor): ?>
                      <tr>
                        <th><?php echo $sub_titulo ?>:</th>
                        <td><?php echo $valor ?></td>
                      </tr>
                    <?php endforeach; ?>
                  </table>
                </div>
              </div>
            </div>
          <?php endif; ?>
          <?php $count2++ ?>
        </div>
      <?php endforeach; ?>
    </div>
  </div>

</div>











